<template>
  <div>
    <p class="title">推荐歌单</p>
    <van-row gutter="6">
      <van-col
        span="8"
        v-for="item in list"
        :key="item.id"
        @click="Go(item.id)"
      >
        <van-image width="100%" height="3rem" :src="item.picUrl" />
        <p class="song_name">{{ item.name }}</p>
      </van-col>
    </van-row>
    <p class="title">最新音乐</p>

    <van-cell
      center
      :title="item.name"
      :label="item.song.artists[0].name + '-' + item.name"
      v-for="item in list2"
      :key="item.id"
    >
      <template #right-icon>
        <van-icon
          name="play-circle-o"
          size="0.6rem"
          @click="play(item.id, item)"
        />
      </template>
    </van-cell>
  </div>
</template>

<script>
import { pushSong } from '@/utils/index.js'
export default {
  methods: {
    play (a, b) {
      console.log(a);
      this.$store.commit('setId', a)
      this.$store.commit('setPlayNum')
      console.log(b);
      pushSong(b)

    },
    Go (id) {
      this.show = true
      this.$store.commit('deitDialogId', id)
      this.$store.commit('deitShow', true)
    }
  },
  async created () {
    let res = await this.axios({
      url: "/personalized",
      params: {
        limit: 6,
      },
    });
    // console.log(res);
    this.list = res.data.result;
    let res2 = await this.axios({
      url: "/personalized/newsong",
      params: {
        limit: 10,
      },
    });
    // console.log(res2);
    this.list2 = res2.data.result;
  },
  data () {
    return {
      list: [],
      list2: [],
    };
  },
};
</script>

<style scoped>
/* 标题 */
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
</style>